package com.wm.book;

import java.util.ArrayList;
import java.util.Collections;

public class BookTest {
    public static void main(String[] args) {
        Book sd = new Book("神雕英雄传",55);
        Book sg = new Book("三国演义",155);
        Book sh = new Book("水浒传",100);
        Book hl = new Book("红楼梦",88);
        ArrayList list = new ArrayList();
        list.add(sd);
        list.add(sg);
        list.add(sh);
        list.add(hl);
        System.out.println("书名\t\t价格");
        for (Object o:list) {
            Book book = (Book)o;
            System.out.println(book.getName() + "\t" + book.getPrice());
        }
        Collections.sort(list);
        System.out.println("*********按价格排序后*********");
        System.out.println("书名\t\t价格");
        for (Object o:list) {
            Book book = (Book)o;
            System.out.println(book.getName() + "\t" + book.getPrice());
        }
    }
}
